 <template>
   <el-card shadow="always" class="box-card">
      <div class="card-name">
        <div class="name width2">资金流水</div>
      </div>
      <div class="content-con">
        <el-form :model="form" ref="form" size="medium" label-width="100px" class="bank-search">
          <el-form-item label="流水单号:" prop="capital_no">
            <el-input v-model="form.capital_no" placeholder="流水单号"></el-input>
          </el-form-item>
          <el-form-item label="供应商编号:" prop="supp_no">
            <el-input v-model="form.supp_no" placeholder="供应商编号"></el-input>
          </el-form-item>
          <el-form-item label="创建日期:" prop="date">
            <el-date-picker
              v-model="form.date"
              type="date"
              format="yyyy-MM-dd"
              placeholder="日期"
              style="width: 100%;">
            </el-date-picker></el-form-item>
            <el-button class="save mb-22 ml-20" @click="search">查 询</el-button>
        </el-form>

        <div class="bank-form">
          <div class="form-item">
            <el-table
              :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
              class="table"
              stripe border
              :header-cell-style="{background:'#f3f3f3',textAlign: 'center'}"
              :cell-style="{ textAlign: 'center' }">
              <el-table-column prop="capital_no" label="流水单号" width="180">
              </el-table-column>
              <el-table-column prop="supp_no" label="供应商编号" width="120">
              </el-table-column>
              <el-table-column prop="supplier" label="供应商名称" width="120">
              </el-table-column>
              <el-table-column prop="not_pay" label="未付款金额(元)" width="120">
              </el-table-column>
              <el-table-column prop="sh_pay" label="应付款金额(元)" width="120">
              </el-table-column>
              <el-table-column prop="add_time" label="时间" width="260">
              </el-table-column>
              <el-table-column prop="note" label="备注" width="160">
              </el-table-column>
              <el-table-column label="操作" width="160">
                <template slot-scope="scope">
                  <el-button type="text" @click="handleView(scope.row)">
                    <i class="el-icon-document"></i>查看
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 分页-页码 -->
          <div class="page">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="pagesize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="tableData.length">
            </el-pagination>
          </div>
        </div>
      </div>
      <capital-view ref="CapitalView" :rows="rows"></capital-view>
   </el-card>

 </template>
<script>
import CapitalView from '@/components/capital/CapitalView';
export default {
  components: {
    CapitalView
  },
  data () {
    return {
      rows: '',
      currentPage: 1, //当前页码
      pagesize: 5,    //每页的数据条数
      tableData: [
        {
          capital_no: 'Z20210303877889',
          supp_no: '1101',
          supplier: '胡波',
          not_pay: '1000',
          sh_pay: '1000',
          add_time: '2021-02-18 11:13:48',
          note: ''
        }
      ],
      form: {
        capital_no: '',
        supp_no: '',
        date: ''
      }
    }
  },

  methods: {
    //搜索
    search() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          console.log(this.form)
          this.$message.success('成功!');
        } else {
          console.log('error submit!!');
          this.$message.error('失败!');
          return false;
        }
      });
    },

    //查看操作
    handleView(row){
      this.rows = row;
      this.$nextTick(()=>{
        this.$refs.CapitalView.openView()
      });
    },

    //每页条数改变时触发事件,选择一页显示多少行
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.currentPage = 1;
      this.pagesize = val;
    },
    // 当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    }
  }
}
</script>
<style lang="scss">

</style>
